﻿# Example of Setup Script
import math

#Function ShortCuts
Add=ExpScope.AddParameter
Get=ExpScope.GetValue
Link = ExpScope.LinkFields
Com=ExpScope.BrukerCommand
File = ExpScope.BrukerFileCommand

#
Com("d2", 1/(4.0*Get("sample.couplings.J_HaCa.average")))
Com("d1", 1.0)
Com("d5", "140u") # 3-9-19 delay

# Pulse Program
File("pulprog", "components.pp1")
Com("o1", Get("spectrometer.ProtonCarrier"))
Com("o2p", Get("sample.spectrum.N.carrier"))
Com("o3p", Get("sample.spectrum.Ca.carrier"))
Com("o4p", Get("sample.spectrum.H2.carrier"))


Com("xcpr", "parmode 2D")

# Hard Pulses
Com("p1", Get("sample.pulses.H1"))
Com("pl1", Get("spectrometer.channels.H1.powerlevel"))
Com("p3", Get("sample.pulses.C13"))
Com("pl2", Get("spectrometer.channels.C13.powerlevel"))
Com("p5", Get("sample.pulses.N15"))
Com("pl3", Get("spectrometer.channels.N15.powerlevel"))

Com("pl19", 60) # water presat (when used)

#CPDs
File("cpdprg4", "components.cpd1")
Com("pcpd4", Get("spectrometer.pulses.Dcpd90"))
#???????????????? pl14 ????????????????
Com("pl4", CalcPower(Get("spectrometer.pulses.Dcpd90"), 1.0, Get("spectrometer.f4.hardpulse"), Get("spectrometer.f4.powerlevel"))) 

# CO decoupling
File("spnam12", "components.wave1")
Com("p12", Get("spectrometer.pulses.COdec90"))
Com("sp12", CalcPower(Get("spectrometer.pulses.COdec90"), GetWaveFactor("components.wave1"), Get("spectrometer.f2.hardpulse"), Get("spectrometer.f2.powerlevel")))
Com("spoal12", 0.5) # no idea what's this
Com("cnst21", Get("sample.spectrum.CO.carrier"))

# Increment times
Com("in0", 0.5/(Get("sample.spectrum.CaCb.sw")*Get("spectrometer.BoField")*Get("spectrometer.indirectCSreference.C13")))
Com("1 td", (0.5/Get("sample.couplings.J_CC.average"))/(0.5/Get("sample.spectrum.CaCb.sw")*Get("spectrometer.BoField")*Get("spectrometer.indirectCSreference.C13")))
Com("2 td", 1024)
Com("1 nd_10", 2)

# Gradients
Com("gpnam1", "SINE.100")
Com("gpnam2", "SINE.100")
Com("gpnam3", "SINE.100")
Com("gpnam4", "SINE.100")
Com("gpz1", 19)
Com("gpz2", 90)
Com("gpz3", 85)
Com("gpz4", 30)

Com("p21", 800)
Com("p22", 1000)
Com("p23", 1000)
Com("p24", 800)

# Acqu Modes
Com("1 FnMODE", "States-TPPI")

# Processing
Com("1 mc2", "States-TPPI")
Com("2 absf1", 4.4)
Com("2 absf2", -1)
Com("2 si", 2048)
Com("2 stsi", 0)
Com("1 si", 512)
Com("1 phc0", 90)
Com("1 phc1", -180)
Com("2 ssb", 2)
Com("1 ssb", 2)
Com("1 PH_mod", "pk")
Com("2 PH_mod", "pk")
Com("1 sf", Get("spectrometer.BoField")/3.97)

